<?
/**
 * Copyright 2008 Melange.
 *
 * This file is part of Melange CMS
 *
 * @package cms
 *
 */


/**
 * Requirements
 */
require_once("mvc/action/ActionForm.php");
require_once("mvc/action/ActionMessage.php");
require_once("mvc/action/ActionMessages.php");



/**
 * BaseSettingForm Class
 *
 * @category    Melange CMS
 * @package     cms
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 */
class BaseSettingForm extends ActionForm {


    // ----------------------------------------------------- Instance Variables


    /**
     * code
     *
     * @var mixed 
     */
    protected $code;


    /**
     * codes
     *
     * @var mixed 
     */
    protected $codes;


    /**
     * more
     *
     * @var mixed 
     */
    protected $more;


    // ----------------------------------------------------------- Constructors


    /**
     * Construct new BaseSettingForm
     */
    public function __construct() {
        $this->code = null;
        $this->codes = array();
        $this->more = 0;
    }


    // ------------------------------------------------------------- Properties


    /**
     * Get Code
     *
     * @return mixed 
     */
    public function getCode() {
        return $this->code;
    }


    /**
     * Set Code
     *
     * @param mixed  code
     */
    public function setCode($code) {
        $this->code = $code;
    }


    /**
     * Get Codes
     *
     * @return mixed 
     */
    public function getCodes() {
        return $this->codes;
    }


    /**
     * Set Codes
     *
     * @param mixed  codes
     */
    public function setCodes($codes) {
        $this->codes = $codes;
    }


    /**
     * Get More
     *
     * @return mixed 
     */
    public function getMore() {
        return $this->more;
    }


    /**
     * Set More
     *
     * @param mixed  more
     */
    public function setMore($more) {
        $this->more = $more;
    }


    // --------------------------------------------------------- Public Methods


    /**
     * Validate this form
     *
     * @return array $errors
     */
    public function validate() {

        $errors = new ActionMessages();

        if(is_null($this->getCode()) || strlen($this->getCode()) == 0)
            $errors->add("code",
                new ActionMessage("errors.required", true, new ActionMessage("label.language", true)));


        if(!is_null($this->getCode()) && strlen($this->getCode()) > 0 && strlen($this->getCode()) > 255)
            $errors->add("code",
                new ActionMessage("errors.maxlength", true, array(
                    new ActionMessage("label.language", true),
                    new ActionMessage("255", false))));


        return $errors;
    }

}
?>